package com.haixiaoke.saas.enterprise.account.yima;

import com.haixiaoke.saas.bill.domain.YmDistrict;
import com.haixiaoke.saas.bill.service.IYmDistrictService;
import com.haixiaoke.saas.common.annotation.TenantScope;
import com.haixiaoke.saas.common.core.domain.AjaxResult;
import com.haixiaoke.saas.common.core.page.TableDataInfo;
import com.haixiaoke.saas.system.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * 翼码地区数据Controller
 *
 * @author qixi
 * @date 2024-06-25
 */
@RestController
@RequestMapping("/enterprise/account/yima/district")
public class EnterpriseYmDistrictController extends BaseController {
    @Autowired
    private IYmDistrictService ymDistrictService;

    /**
     * 查询翼码地区数据列表
     */
    @GetMapping("/list")
    public TableDataInfo list(YmDistrict ymDistrict) {
        startPage();
        List<YmDistrict> list = ymDistrictService.selectYmDistrictList(ymDistrict);
        return getDataTable(list);
    }

    /**
     * 获取省
     *
     * @return
     */
    @GetMapping("/province/list")
    @TenantScope
    public AjaxResult provinceList() {
        List<YmDistrict> list = ymDistrictService.selectYmDistrictProvinceList();
        return success(list);
    }


    /**
     * 根据省份编码获取城市列表
     */
    @GetMapping(value = "/city/{provinceCode}")
    @TenantScope
    public AjaxResult cityList(@PathVariable("provinceCode") String provinceCode) {
        return success(ymDistrictService.selectYmDistrictCityListByProvinceCode(provinceCode));
    }

    /**
     * 根据省份编码获取城市列表
     */
    @GetMapping(value = "/area/{provinceCode}/{cityCode}")
    @TenantScope
    public AjaxResult areaList(@PathVariable("provinceCode") String provinceCode, @PathVariable("cityCode") String cityCode) {
        return success(ymDistrictService.selectYmDistrictCityListByProvinceCodeAndCityCode(provinceCode, cityCode));
    }


}
